<?php

namespace app\index\model;

use think\Model;

class Comcoll extends Model
{
    /**
     * @param $user
     * @param $company
     * @return Comcoll
     * ljj
     * 查看是否关注
     */
    public function isFollow($user,$company)
    {
        return $this
            ->where('user_id','=',$user)
            ->where('company_id','=',$company)
            ->where('is_delete','=','0')
            ->find();
    }

    /**
     * @param $userId
     * @param $companyId
     * @return Comcoll
     * ljj
     * 取消关注
     */
    public function UnFollow($userId,$companyId)
    {
        return $this->where('user_id','=',$userId)->where('company_id','=',$companyId)->update(['is_delete'=>1]);
    }

    /**
     * @param $insetFollow
     * @return bool
     * ljj
     * 关注接口
     */
    public function Follow($insetFollow)
    {
        return $this->save($insetFollow);
    }

    /**
     * @param $user
     * @param $companyId
     * @return void
     * ljj
     * 关注（数据库有数据时）
     */
    public function updateFollow($user,$companyId)
    {
        $this
        ->where('user_id','=',$user)
        ->where('company_id','=',$companyId)
        ->update(['is_delete'=>'0']);
    }
}